from django.http import HttpResponse
from django.shortcuts import render
# from django.template import RequestContext, loader
from .models import BookInfo

def index(request):
    booklist = BookInfo.objects.all()
    context = {'booklist':booklist}
    return render(request,'booktest/index.html',context)
    #template = loader.get_template('booktest/index.html')
    # context = RequestContext(request, {'booklist': booklist})
    # context = {'booklist':booklist}
    # return HttpResponse(template.render(context))


def detail(request, id):
    book = BookInfo.objects.get(pk=id)
    context = {'book':book}
    return render(request,'booktest/detail.html',context)
    # template = loader.get_template('booktest/detail.html')
    # context = RequestContext(reqeust, {'book': book})
    # context = {'book':book}
    # return HttpResponse(template.render(context))